package utils

import (
	"context"
	"github.com/aliyun/fc-runtime-go-sdk/fccontext"
	"log"
	"os"
)

func EchoLog(ctx context.Context, level string, s string) {
	if os.Getenv("FC_FUNCTION_NAME") != "" {
		fCtx, _ := fccontext.FromContext(ctx)
		switch level {
		case "debug":
			fCtx.GetLogger().Debug(s)
		case "warn":
			fCtx.GetLogger().Warn(s)
		default:
			fCtx.GetLogger().Info(s)
		}

		return
	}

	log.Println(s)
}
